﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
 
namespace StuEdu.Web.Attendance
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int attendanceId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(attendanceId);
				}
			}
		}
			
	private void ShowInfo(int attendanceId)
	{
		StuEdu.BLL.Attendance bll=new StuEdu.BLL.Attendance();
		StuEdu.Model.Attendance model=bll.GetModel(attendanceId);
		this.lblattendanceId.Text=model.attendanceId.ToString();
		this.txtstuNo.Text=model.stuNo.ToString();
		this.txtattendanceState.Text=model.attendanceState.ToString();
		this.chkattendanceStyle.Checked=model.attendanceStyle;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtstuNo.Text))
			{
				strErr+="stuNo格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtattendanceState.Text))
			{
				strErr+="attendanceState格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int attendanceId=int.Parse(this.lblattendanceId.Text);
			int stuNo=int.Parse(this.txtstuNo.Text);
			int attendanceState=int.Parse(this.txtattendanceState.Text);
			bool attendanceStyle=this.chkattendanceStyle.Checked;


			StuEdu.Model.Attendance model=new StuEdu.Model.Attendance();
			model.attendanceId=attendanceId;
			model.stuNo=stuNo;
			model.attendanceState=attendanceState;
			model.attendanceStyle=attendanceStyle;

			StuEdu.BLL.Attendance bll=new StuEdu.BLL.Attendance();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
